home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8170 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1000 b 

  1. Path: wilde.oit.umass.edu!not-for-mail
  2. From: ksexton@wilde.oit.umass.edu (Kevin M Sexton)
  3. Newsgroups: comp.lang.c
  4. Subject: Problem with a for loop
  5. Date: 2 Mar 1996 03:41:09 GMT
  6. Organization: University of Massachusetts, Amherst
  7. Message-ID: <4h8g0l$1ot@nic.umass.edu>
  8. NNTP-Posting-Host: oitunix.oit.umass.edu
  9. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  10.  
  11. Hi.
  12. I was doing a project for one of my classes and I came across a rather 
  13. odd bug in part of the code.  I initially had the following:
  14. for ( i = 0; WL[i] != NULL, i <= 10; i++ )
  15. {
  16.     AAL[i] = new char[strlen(WL[i])+1);
  17.     strcpy(AAL[i], WL[i]);
  18. }
  19.  
  20. I realize that new belongs to C++, but that's not where the confusion 
  21. lies.  WL is an array of pointers to strings.  WL[0]="./my_macro" and
  22. WL[1]=NULL.  However, the for loop insists on continuing the loop even 
  23. when i=1 and WL[i]=NULL.  Am I missing something?  I can't see what is 
  24. wrong logically.  Any assistance would be much appreciated.  Thanx in 
  25. advance.
  26.  
  27. Kevin
  28. ksexton@wilde.oit.umass.edu
  29.  
  30.